package com.ruoyi.web.admin.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysDeviceCollectRecord;
import com.ruoyi.system.service.ISysDeviceCollectRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 10100
 */
@Api(tags = "设备采集记录管理")
@RestController
@RequestMapping("/system/deviceCollectRecord")
public class SysDeviceCollectRecordController extends BaseController {
    private final ISysDeviceCollectRecordService sysDeviceCollectRecordService;

    public SysDeviceCollectRecordController(ISysDeviceCollectRecordService sysDeviceCollectRecordService) {
        this.sysDeviceCollectRecordService = sysDeviceCollectRecordService;
    }

    @ApiOperation("查询设备采集记录列表")
    @PreAuthorize("@ss.hasPermi('system:deviceCollectRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDeviceCollectRecord record) {
        startPage();
        List<SysDeviceCollectRecord> list = sysDeviceCollectRecordService.selectSysDeviceCollectRecordList(record);
        return getDataTable(list);
    }

    @ApiOperation("获取设备采集记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:deviceCollectRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam("主键ID") @PathVariable("id") Long id) {
        return success(sysDeviceCollectRecordService.selectSysDeviceCollectRecordById(id));
    }

    @ApiOperation("新增设备采集记录")
    @PreAuthorize("@ss.hasPermi('system:deviceCollectRecord:add')")
    @Log(title = "设备采集记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDeviceCollectRecord record) {
        return toAjax(sysDeviceCollectRecordService.insertSysDeviceCollectRecord(record));
    }

    @ApiOperation("修改设备采集记录")
    @PreAuthorize("@ss.hasPermi('system:deviceCollectRecord:edit')")
    @Log(title = "设备采集记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDeviceCollectRecord record) {
        return toAjax(sysDeviceCollectRecordService.updateSysDeviceCollectRecord(record));
    }

    @ApiOperation("删除设备采集记录")
    @PreAuthorize("@ss.hasPermi('system:deviceCollectRecord:remove')")
    @Log(title = "设备采集记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("主键ID数组") @PathVariable Long[] ids) {
        return toAjax(sysDeviceCollectRecordService.deleteSysDeviceCollectRecordByIds(ids));
    }
} 